package cn.imnaer.service.rpc.feedback.dao;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;

import org.bson.BSONObject;
import org.bson.BasicBSONObject;

import cn.imnaer.common.factory.TimeHelper;
import cn.imnaer.database.BaseDao;
import cn.imnaer.database.MatchConst;
import cn.imnaer.database.define.DBConstant;
import cn.imnaer.service.persistence.model.Version;

public class VersionDaoImpl extends BaseDao<Version> {
	
	
	private  static  VersionDaoImpl  instance=new  VersionDaoImpl();
    private    VersionDaoImpl() {
      
    }
    
    public  static   VersionDaoImpl   getInstance(){
    	
    	return  instance;
    	
    }

	public Version getCurrentVersion() {
		BSONObject matcher=new  BasicBSONObject() ;
		BSONObject exist=new  BasicBSONObject() ;
		exist.put(MatchConst._EXISTS, 1);
		matcher.put("version",exist);
		BSONObject orderBy=new BasicBSONObject();
		orderBy.put("createTime", -1);
	return 	this.findOne(matcher, orderBy);
		
	}
	public Version getSmallVersion() {
		BSONObject matcher=new  BasicBSONObject() ;
		matcher.put("createTime", 0);
	return 	this.findOne(matcher, null);
		
	}

		@Override
		protected String getDbSpaceName() {
			return DBConstant.SPACE.USER_INFO_SPACE;
		}

		@Override
		protected String getDbCollectionName() {
			return DBConstant.COLLECTION.CLIENT_VERSION_INFO_COLLECTION;
		}

		@Override
		protected String getPrimaryKey() {
			return  null;
		}
    
}
